//
//  ZQVistorTableViewController.swift
//  Sina Blog
//
//  Created by 张强 on 16/5/11.
//  Copyright © 2016年 张强. All rights reserved.
//

import UIKit

class ZQVistorTableViewController: UITableViewController {
   var userLogin = false
    var  vistorView: ZQVistorView?
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
      
        vistorView!.callBack = { [weak self] in
            self?.requestLoading()
            
        }

    
    }
    
   private func requestLoading() {
        let vc = ZQOAuthViewController()
        let nav = UINavigationController.init(rootViewController: vc)
        
        self.presentViewController(nav, animated: true, completion: nil)

    
    }
    
    
    override func loadView() {
        if userLogin {
            super.loadView()
        }else {
        
            vistorView = ZQVistorView()
            
            view = vistorView
                      setupUI()
        
        
        }
    }
    
    
    private func setupUI() {
        navigationItem.leftBarButtonItem = UIBarButtonItem.init(title: "注册", style: .Plain, target: self, action: #selector(registClick))
        
        navigationItem.rightBarButtonItem = UIBarButtonItem.init(title: "登陆", style: .Plain, target: self, action: #selector(loginClick))
    
    
    }
    
    @objc private func registClick() {
        
        requestLoading()
    
    }
    
  
    
    @objc private func loginClick() {
        requestLoading()
    
    }
    
    
    
    
    
    
}
